<template>
  <div class="interaction-start">
    <div class="container">
      <div class="box-left">
        <div class="section">
          <div class="case-tip">
            <div class="case-tipName">{{cases.resourceCaseName}}</div>
            <div class="sm-group">
              <el-button type="text" size="mini" icon="el-icon-s-custom">{{cases.resourceGroupName}}</el-button>
              <el-button type="text" size="mini" icon="el-icon-s-grid">{{cases.nodeNum}}个环节</el-button>
            </div>
          </div>
          <!--<div class="train-info">-->
          <!--当前得分：87 排名：第五名-->
          <!--</div>-->
          <div class="case-con">{{cases.caseRequestEn}}</div>
        </div>
        <div class="section">
          <div class="case-tip">实训小组</div>
          <div class="list-box">
            <ul>
              <li v-for="(item, index) in scores.stuGroupAndScoreList" :key="index" :class="{'cursor': item.answerFlag === '1'}" @click="viewOther(item)">
                <el-button type="text" size="mini" icon="el-icon-s-custom">{{item.stuGroupName}}</el-button>
                <span class="right-arrow" v-if="item.answerFlag === '1'">{{item.score}}分<i class="el-icon-arrow-right"></i></span>
                <span class="right-arrow" v-else>未评分</span>
              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="box-right">
        <!-- 案例背景 -->
        <div class="case-tip">案例背景</div>
        <el-carousel trigger="click" height="500px" :loop="false">
          <el-carousel-item v-for="(item, index) in cases.resourceCaseBgList" :key="index">
            <!-- 纯文本 -->
            <div class="media-box" v-if="item.displayType === '1'">
              <div class="case-con">{{item.resourceCaseContentEn}}</div>
            </div>
            <!-- 图片 -->
            <div class="media-box" v-if="item.displayType === '2'">
              <img :src="item.fileUrl" style="max-width:100%;max-height:100%;display: block;margin: 0 auto;">
            </div>
            <!-- 音频 -->
            <div class="media-box" v-if="item.displayType === '3'">
              <audio class="audio" controls :src="item.fileUrl"></audio>
            </div>
            <!-- 视频 -->
            <div class="media-box" v-if="item.displayType === '4'">
              <video class="video" controls :src="item.fileUrl">
                <track :src="item.fileUrl" lang="en" label="English" kind="subtitles" default />
              </video>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
    <answer-box :resourceCaseId="resourceCaseId" :answerItem="answerItem" v-if="isShowAnswer" @handleEmit="isShowAnswer=false"/>
  </div>
</template>

<script>
import { trainingInteraction, trainingInteractionMain, nodeScore } from '@/api/teacher/manage/trainingInteractionManage'
import answerBox from './interactionAnswerBox'
export default {
  name: 'interactionComment',
  data () {
    return {
      resourceCaseId: this.$route.query.id,
      caseNodeId: this.$route.query.caseNodeId,
      caseNodeName: this.$route.query.caseNodeName,
      cases: {
        nodeNum: '',
        resourceCaseId: '',
        resourceCaseName: '',
        resourceGroupName: '',
        caseRequestCn: '',
        caseRequestEn: '',
        resourceCaseBgList: [],
        finishedFlag: '',
        lessonICaseId: '',
        classNames: '',
        currentCaseNodeName: '',
        isGroup: '',
        stuNo: ''
      },
      mains: {
        caseRequestCn: '',
        caseRequestEn: '',
        lessonICaseId: '',
        nodeList: [],
        nodeNum: '',
        resourceCaseBgList: [],
        resourceCaseId: '',
        resourceCaseName: '',
        resourceGroupName: ''
      },
      scores: {
        resourceCaseId: '',
        resourceCaseName: '',
        caseRequestCn: '',
        caseRequestEn: '',
        resourceCaseBgList: [],
        caseNodeId: '',
        lessonICaseId: '',
        stuGroupAndScoreList: []
      },
      isShowAnswer: false,
      answerItem: {},
      btnDisabled: false
    }
  },
  components: {
    answerBox
  },
  mounted () {
    this.trainingInteraction()
  },
  methods: {
    async trainingInteraction () {
      const res = await trainingInteraction({ resourceCaseId: this.resourceCaseId })
      if (res.code === '200') {
        this.cases = res.data
        this.trainingInteractionMain()
        this.nodeScore()
      } else {
        this.$message.error(res.message)
      }
    },
    async trainingInteractionMain () {
      const res = await trainingInteractionMain({ lessonICaseId: this.cases.lessonICaseId })
      if (res.code === '200') {
        this.mains = res.data
      } else {
        this.$message.error(res.message)
      }
    },
    async nodeScore () {
      const res = await nodeScore({
        caseNodeId: this.caseNodeId,
        lessonICaseId: this.cases.lessonICaseId
      })
      if (res.code === '200') {
        this.scores = res.data
      } else {
        this.$message.error(res.message)
      }
    },
    viewOther (item) {
      if (item.answerFlag === '1') {
        this.$router.push({
          name: 'interactionCommentOther',
          query: {
            id: this.resourceCaseId,
            caseNodeId: this.caseNodeId,
            caseNodeName: this.caseNodeName,
            stuGroupId: item.stuGroupId
          }
        })
      }
    }
  }
}
</script>
<style scoped lang="scss" rel="stylesheet/scss">
  .interaction-start {
    .container {
      display: flex;
      justify-content: space-between;
      .box-left {
        width: 550px;
        background: #fff;
        padding: 15px;
        .section {
          .sm-group{
            margin-top: 10px;
          }
          .train-info {
            color: #BBBBBB;
            font-size: 14px;
            margin-top: 10px;
          }
          .content {
            color: #BBBBBB;
            font-size: 14px;
            padding:20px 0;
            line-height: 1.2;
          }
          .card {
            border-radius: 20px;
            background: #f5f5f5;
            width: 455px;
            margin: 0 auto;
            .row {
              display: flex;
              align-items: center;
              justify-content: space-between;
            }
            .row-1{
              padding: 0 20px;
              line-height: 60px;
              border-bottom: 1px solid #D2D2D2;
            }
            .row-2{
              padding: 0 60px;
              line-height: 50px;
            }
          }
          .list-box {
            margin-top: 20px;
            ul {
              li {
                line-height: 60px;
                font-size: 14px;
                border-bottom: 1px solid #f5f5f5;
                padding: 0 10px;
                position: relative;
                i{
                  margin-left: 10px;
                }
                &:hover {
                  background: #f5f5f5;
                }
                &.cursor {
                  cursor: pointer;
                }
                .right-arrow {
                  position: absolute;
                  right: 10px;
                }
              }
            }
          }
        }
      }
      .box-right {
        width: 630px;
        min-height: 100%;
        background: #fff;
        padding: 15px;
        box-sizing: border-box;
        .title {
          font-size: 14px;
          font-weight: bold;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .tab {
            display: flex;
            .tab-item {
              width: 85px;
              line-height: 40px;
              border: 1px solid #D9D9D9;
              text-align: center;
              font-weight: initial;
              cursor: pointer;
              &.active {
                border: 1px solid #828282;
              }
            }
          }
          .time {
            font-size: 14px;
            color: #828282;
            position: absolute;
            right: 0;
            font-weight: normal;
          }
        }
        .content {
          color:#BBBBBB;
          font-size: 14px;
          padding:20px 0;
          line-height: 1.2;
        }
        .media-box {
          padding: 15px 0;
          .video {
            width: 100%;
          }
        }
        .file-box {
          line-height: 40px;
          display: flex;
          justify-content: space-between;
          border-bottom: 1px solid #f5f5f5;
          font-size: 14px;
          font-weight: bold;
          a {
            color: #009cf6;
            font-weight: normal;
          }
        }
        .fill-box {
          .fill-title {
            font-size: 14px;
          }
          textarea {
            width: 100%;
            margin-top: 20px;
          }
        }
        .report-box {
          li {
            line-height: 70px;
            position: relative;
            .right-arrow {
              position: absolute;
              right: 0;
            }
            textarea {
              width: 100%;
              margin-top: 20px;
            }
          }
        }
        .wait-btn, .submit-btn {
          width: 100%;
          line-height: 40px;
          border-radius: 10px;
          background: #BBBBBB;
          color: #fff;
          text-align: center;
          margin-top: 30px;
          cursor: pointer;
        }
      }
    }
  }
  .inter-checkbox{
    display: block;
    margin: 15px 0;
    overflow: hidden;
  }

  .inter-checkbox .el-checkbox__input{
    float: right;
  }

  .inter-checkbox .el-checkbox__label{
    float: left;
  }

  .inter-chooseBox{
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    padding: 15px;
    border-radius: 10px;
    background: #eee;
  }
  .inter-chooseL{
    width: 440px;
  }
  .inter-className{
    margin-bottom: 10px;
    line-height: 20px;
    font-weight: bold;
  }
  .inter-chooseR{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100px;
    text-align: center;
  }
  .inter-tip{
    width: 100%;
    line-height: 18px;
  }
  .inter-histBox{
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    padding: 20px 10px;
    margin: 20px 0;
    cursor: pointer;
  }
  .inter-btn{
    width: 100%;
  }
</style>
